package main

import (
	"flag"
	"fmt"
	"os"
	"path/filepath"
	"runtime"
	"time"

	business "Projects/CavaCloudSys/cavateusrc/com.business"
	qfcfg "Projects/CavaCloudSys/cavateusrc/com.qfcfg"

	qflog "github.com/qf-tech/qftech-base/pkg/log"
)

func main() {
	config := &qflog.LogConfig{
		MaxCount: 90,
		MaxSize:  30,
		Compress: true,
		FilePath: "./log/server.log",
		Level:    qflog.InfoLevel,
		Format:   qflog.JsonType,
	}

	qflog.Init(config)
	qfcfg.InitConfig()

	// 打印版本信息
	path, _ := os.Executable()
	_, svrName := filepath.Split(path)
	flag.Parse()
	if option.PrintVersion {
		fmt.Printf("%s %s %s (Git SHA: %s, Go Version: %s, BuildAt: %s)\n", svrName, GitBranch, Version, GitSHA, runtime.Version(), BuildAt)
		os.Exit(0)
	}

	var demo business.Controller
	demo.Init()

	fmt.Println("cava teu start.")

	for {
		demo.Start()
		// 重试间隔必须大于心跳周期
		time.Sleep(60 * time.Second)
	}
	// select {}
}
